﻿using System.Collections.Generic;

namespace SixthSense
{
    class Profile
    {
        private string _Name;

        private MaterialInfoList _Materials = new MaterialInfoList();
        private AlertInfoList _Alerts = new AlertInfoList();
        private AlertInfoList _Monsters = new AlertInfoList();
        private AlertInfoList _Items = new AlertInfoList();
        private AlertInfoList _Special = new AlertInfoList();

        public Profile Copy()
        {
            Profile p = (Profile)this.MemberwiseClone();
            p.Materials = p._Materials.Copy();
            p._Alerts = p._Alerts.Copy();
            p._Monsters = p._Monsters.Copy();
            p._Items = p._Items.Copy();
            p._Special = p._Special.Copy();

            return p;
        }

        public void Clear()
        {
            _Alerts.Clear();
            _Materials.Clear();
            _Name = "";
        }

        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }

        public AlertInfoList Alerts
        {
            get
            {
                return _Alerts;
            }
            set
            {
                _Alerts = value;
            }
        }

        public MaterialInfoList Materials
        {
            get
            {
                return _Materials;
            }
            set
            {
                _Materials = value;
            }
        }

        public System.Collections.IEnumerable Monsters
        {
            get
            {
                _Monsters = _Alerts.FindAllByType("monster");

                foreach (AlertInfo a in _Monsters)
                {
                    yield return a;
                }
            }
        }

        public System.Collections.IEnumerable Item
        {
            get
            {
                _Items = _Alerts.FindAllByType("loot");

                foreach (AlertInfo a in _Items)
                {
                    yield return a;
                }
            }
        }

        public System.Collections.IEnumerable Special
        {
            get
            {
                _Special = _Alerts.FindAllByType("special");

                foreach (AlertInfo a in _Special)
                {
                    yield return a;
                }
            }
        }
    }

    class ProfileList : List<Profile>
    {
        public Profile FindByName(string Item)
        {
            Profile FoundProfile = this.Find(o => o.Name.ToLower() == Item.ToLower());

            return FoundProfile;
        }
    }
}
